12 步:是时候开始计算精灵之间的距离了。

  • 单击工具包中的 LOGIC 选项卡,单击并拖出Delta X
  • 将等号右侧的x2变量替换为emma_x
  • 将等号右侧的x1变量替换为michael_x

delta_x现在等于 Emma 和 Michael 的 x 坐标之间的距离。

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("schoolentrance") stage.wait(2) stage.create_grid_overlay(50, "blue") stage.set_background_color("azure") emma = codesters.Sprite("person1") emma.set_size(0.5) michael = codesters.Sprite("person2") michael.set_size(0.5) emma_x = random.randint(-230,230) emma_y = random.randint(-230,230) emma.go_to(emma_x, emma_y) michael_x = random.randint(-230,230) michael_y = random.randint(-230,230) michael.go_to(michael_x, michael_y)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)